#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n, k, x;
    cin >> n >> k >> x;

    vector<vector<int>> matrix(n, vector<int>(n));
    // 读取矩阵元素
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> matrix[i][j];
        }
    }

    // 对奇数行进行平移操作
    for (int i = 0; i < n; i += 2) {
        int shift = (i / 2) % k + 1;
        vector<int> temp(n);
        for (int j = 0; j < shift; ++j) {
            temp[j] = x;
        }
        for (int j = shift; j < n; ++j) {
            temp[j] = matrix[i][j - shift];
        }
        matrix[i] = temp;
    }

    // 计算每列元素的和
    vector<int> columnSums(n, 0);
    for (int j = 0; j < n; ++j) {
        for (int i = 0; i < n; ++i) {
            columnSums[j] += matrix[i][j];
        }
    }

    // 输出结果
    for (int i = 0; i < n; ++i) {
        if (i > 0) {
            cout << " ";
        }
        cout << columnSums[i];
    }
    cout << endl;

    return 0;
}    